#! /bin/bash

#log()
#{
 #   echo "$@" >>$logfile
#}

#log BEGIN $1

:<<EOF

if test "$E1" != 0 || test "$E2" = 0; then
    echo "Broken shell detected.  Trying alternatives."
    export FF_CONF_EXEC
    if test "0$FF_CONF_EXEC" -lt 1; then
        echo "0$FF_CONF_EXEC"
	FF_CONF_EXEC=1
        try_exec bash "$0" "$@"
    fi
    if test "0$FF_CONF_EXEC" -lt 2; then
	 echo "0$FF_CONF_EXEC"
        FF_CONF_EXEC=2
        try_exec ksh "$0" "$@"
    fi
    if test "0$FF_CONF_EXEC" -lt 3; then
	 echo "0$FF_CONF_EXEC"
        FF_CONF_EXEC=3
        try_exec /usr/xpg4/bin/sh "$0" "$@"
    fi
    echo "No compatible shell script interpreter found."
    echo "This configure script requires a POSIX-compatible shell"
    echo "such as bash or ksh."
    echo "THIS IS NOT A BUG IN FFMPEG, DO NOT REPORT IT AS SUCH."
    echo "Instead, install a working POSIX-compatible shell."
    echo "Disabling this configure test will create a broken FFmpeg."
    if test "$BASH_VERSION" = '2.04.0(1)-release'; then
        echo "This bash version ($BASH_VERSION) is broken on your platform."
        echo "Upgrade to a later version if available."
    fi
    exit 1
fi
 


log()
{
    shift
    echo "$@"
}
log jin yong bin 

set_all()
{
    value=$1
    shift
    for var in $*;do
eval  $var=$value
    done
for var in $*;do
    eval echo \$$var
done
}
set_all yes jin yong bin
EOF

:<<EOF

pushvar(){
    for var in $*; do
        eval level=\${${var}_level:=0}
	     eval ${var}_${level}="\$$var"
        eval ${var}_level=$(($level+1))

    done

}

popvar(){
    for var in $*; do
        eval level=\${${var}_level:-0}
        test $level = 0 && continue
        eval level=$(($level-1))
        eval $var="\${${var}_${level}}"
        eval ${var}_level=$level
        eval unset ${var}_${level}
    done
}
a=1
pushvar a
a=2
pushvar a
a=3
pushvar a
popvar a
popvar a
popvar a

echo_all()
{
    for var;do
	echo $var
	done
}
echo_all a b c d e f
EOF

# test sed 
:<<EOF
sed s/Makefile/\ \ \`pwd\`/g testfile
EOF

# test shell pwd
PWD=shell pwd
echo ${PWD}